import QtQuick 2.2
Rectangle{
    width: 300; height: 200
	id: root;
    property var person: new Object();
    function replacer(key, value){
        switch(key){
        case "name":
            return "Zhang San";
        }
        return value;
    }

    property var array: new Array();
    Component.onCompleted: {
        array[0] = "version";
        array[1] = "2.3"
        console.log(JSON.stringify(array));

        person.name = "zhangsan";
        person.moblie = "13888888888";
        person.age = 20;
        person.contury = "China";

        console.log(JSON.stringify(person));
        console.log(JSON.stringify(person, null, 4));
        console.log(JSON.stringify(person, ["moblie", "name"], " "));
        console.log(JSON.stringify(person, replacer));

        person.toJSON = function(){
            var replacement = new Object();
            for (var p in this){
                if (typeof(this[p]) == 'string'){
                    replacement[p] = this[p].toUpperCase();
                }else{
                    replacement[p] = this[p];
                }
            }
            return replacement;
        }
        console.log(JSON.stringify(person));
    }
}
